package com.xinhe.web.controller;

import com.querydsl.core.QueryResults;
import com.xinhe.web.annotation.WebUsed;
import com.xinhe.web.common.Result;
import com.xinhe.web.response.TeamBuyDetailView;
import com.xinhe.web.response.TeamBuyView;
import com.xinhe.web.service.TeamBuyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@Api(value = "组团购买详情", tags = {"组团购买详情"})
@RestController
@RequestMapping(value = {"/teamBuy"}, produces = {"application/json;charset=UTF-8"})

public class TeamBuyController {
    @Autowired
    private TeamBuyService teamBuyService;

    @ApiOperation(httpMethod = "GET", value = "分页查询组团购买详情")
    @RequestMapping({"/pageTeamBuy"})
    public QueryResults<TeamBuyView> pageTeamBuy(Long leaderUserId, Long teamGoodsId, Long goodsId, Integer memberAmount,
                                                 Integer joinAmount, Integer payAmount, String status,
                                                 Date startTime, Date endTime, String remark, Integer progress,
                                                 int pageNum, int pageSize) {
        return this.teamBuyService.pageTeamBuy(leaderUserId,  teamGoodsId,  goodsId,  memberAmount,
                 joinAmount,  payAmount,  status,
                 startTime,  endTime, remark,  progress,pageNum,  pageSize);
    }

    @WebUsed
    @ApiOperation(httpMethod = "GET", value = "分页查询组团购买详情(平台)")
    @RequestMapping({"/pageTeamBuyPlatform"})
    public QueryResults<TeamBuyView> pageTeamBuyPlatform(Long leaderUserId, Long teamGoodsId, Long goodsId, Integer memberAmount,
                                                       Integer joinAmount, Integer payAmount, String status,
                                                       Date startTime, Date endTime, String remark, Integer progress,
                                                       int pageNum, int pageSize) {
        return this.teamBuyService.pageTeamBuyPlatform(leaderUserId,  teamGoodsId,  goodsId,  memberAmount,
                joinAmount,  payAmount,  status,
                startTime,  endTime, remark,  progress,pageNum,  pageSize);
    }
    @ApiOperation(httpMethod = "POST", value = "保存组团购买详情")
    @RequestMapping({"/saveTeamBuy"})
    public Result saveTeamBuy(Long leaderUserId,Long teamGoodsId, Long goodsId, Integer memberAmount,
                              Integer joinAmount, Integer payAmount,
                              String status, Date startTime, Date endTime, String remark) {
        return this.teamBuyService.saveModel(leaderUserId,  teamGoodsId,  goodsId,  memberAmount,
                joinAmount,  payAmount,  status,
                startTime,  endTime, remark);
    }
    @ApiOperation(httpMethod = "GET", value = "删除组团购买详情")
    @ApiImplicitParam(name = "teamBuyId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/deleteTeamBuy"})
    public Result deleteTeamBuy(Long teamBuyId) {
        return this.teamBuyService.delete(teamBuyId);
    }
    @ApiOperation(httpMethod = "GET", value = "组团购买详情详情")
    @ApiImplicitParam(name = "teamBuyId", value = "标识", dataTypeClass = Long.class, required = true)
    @RequestMapping({"/detailTeamBuy"})
    public Result<TeamBuyDetailView> detailTeamBuy(Long teamBuyId) {
        return this.teamBuyService.detailTeamBuy(teamBuyId);
    }
}
